JBoss Community Archive (Read Only)

RHQ

Canned DynaGroup expressions

When you want to define a dynagroup, you can either type in the expression yourself or compose them via the wizard. A third alternative for common cases is to use canned expressions:

images/author/download/attachments/75990413/Screenshot 2013-12-09 14.55.34.png

Unfortunately those expressions are hard coded in the server(1) and can't easily be added to by 3rd parties

1) Technically speaking in org.rhq.coregui.client.inventory.groups.definitions.SingleGroupDefinitionView#getTemplates

Proposal

We should put the definitions into the plugins so that plugin developers can define standard canned expressions, which can then be displayed in the servers list of expressions.

Format

The expressions should live in their own file inside plugin.jar!META-INF/ and not be part of the plugin-descriptor, as the latter one is already too big and complicated. We should update the plugin verification tool in a way that a developer can cross check that the names for types and metrics in the expression match the ones from the descriptor.

The format of the template could be anything - I would expect not to use XML, as any of those reserved chars like <,>,& etc.
would need CDATA sections images/author/images/icons/emoticons/help_160.gif

JSON or Yaml come to mind. The following shows an example on how this looks like in JSON:

{ "expressions": [
   { "name": "Group EAP6 standalone servers",
      "expression": ["groupby resource.type",
                "resource.type.name = EAP6 Standalone Server",
                "resource.plugin.name = AS7 plugin"],
      "deployByDefault": true,
      "recalcInMinutes": 5
      "description": "This template deploys a dynagroup that will contain all EAP6 standalone servers"
   },
   { "name": .... }
 ]
}

Inside the individual expression, we would have a name/description that is shown in the drop down and the template text. In the above example individual lines of the template are put into elements of an array of strings that is then (literally) put into the editor textbox.

As more than one plugin could define an expression with the same name, we need to make sure that the display for the user includes the plugin name as first part of the name (if we stay with a dropdown); if we create a more sophisticated editor, we should allow to sort by plugin name and expression name.

The above example contains two more entries that may need explanation:

  • deployByDefault : if this is present and set to true, then we will on deploy of the plugin create a DynaGroup from the entry. And probably also:

  • recalcInMinutes: automatically recalculate the expression every given minutes. A value of 0 switches recalculation off. Only positive integer values are allowed

Server side storage

We could store the expressions in the database in a separate table (possibly just the whole JSON string in a clob). Deploying a new plugin would add new templates, update existing and remove ones that are no longer in the plugin. As alternative we could also leave them in the plugins and dynamically populate the dropdown / list of templates from the plugins when the user wants to create a new DynaGroup. This is possible as we do not relationally refer to the templates, but copy their content when the user selects one.

UI handling

As the list could grow large with many plugins, we should think of allowing to filter entries

  • by name

  • by plugin

As we already have the DynaGroup-Wizard and the input field to write such expressions, a user with INVENTORY_MANAGER could get additional buttons and fields to store such an expression and also remove user generated expressions. The user generated expressions could get a "plugin name" of "User" (or " User" to sort them in the list to the top). or similar. Also we must make sure that the canned expressions will now show the delete button.

Agent side handling

Agents do not need access to the dynagroup expressions, so they do not need to touch or parse that descriptor

Lifecycle on the server

When a plugin is parsed on the server, the canned expressions are just added to the list of available expressions if they are not yet there. If they already exist, they are replaced. Expressions for a plugin that are no longer provided by the plugin are deleted.

When a plugin is deleted (removed, purged, killed) the expressions of it are removed - especially as killing a plugin also removes all its resource types and resources of that type.

User defined expressions just stay until the user cleans them up.

Questions:

  • Should the user be allowed to define such canned expressions on his own: YES

    • If yes: how can an end user define entries on his own? One possibility could be to write an empty plugin that just holds those values.

    • Use some additional UI elements to save / delete what the user has provided in the textfield

  • Should a template with deployByDefault=true be deleted on plugin undelete? If the resources defined by the plugin are gone, the expression is probably no longer needed: YES

  • Should a template with deployByDefault=true be hidden from the user? I think the user may still want to use that as a template for his own trials, so we should offer it, but without any automatic recalculations

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 12:49:50 UTC, last content change 2014-02-03 12:37:41 UTC.